package com.sxd.bill.rela.util;

import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

public class Joiner {
    public static String join(List<String> entities, String prefix, String suffix) {
        entities.sort(Comparator.comparingInt(String::length).reversed());
        return entities.stream().map(ent -> prefix + ent + suffix).collect(Collectors.joining("|"));
    }

    public static String join(List<String> entities) {
        return join(entities, "", "");
    }
}
